class Page(object):
    '''页面基础类，用于所有页面的继承'''
    bbs_url = "https://www.jd.com"

    def __init__(self,selenium_driver,base_url =bbs_url,parent=None):
        self.base_url = base_url
        self.driver = selenium_driver
        self.timeout = 30
        self.parent=parent

    def _open(self,url):
        url =self.base_url+url
        self.driver.get(url)
        assert self.on_page(),'Did not land on %s'%url
    #定位单个与多个元素
    def find_elemnet(self,*loc):
        return self.driver.find_element(*loc)
    def find_elements(self,*loc):
        return self.driver.find_elements(*loc)
    # 打开京东地址
    def open(self):
        self._open(self.url)
    def on_page(self):
        return self.driver.current_url ==(self.base_url+self.url)
    #调用JavaScript代码
    def script(self,src):
        return self.driver.execute_script(src)
